﻿using System;
using System.Threading;

namespace Program14
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Console.WriteLine("主线程");
            Thread t = new Thread(new ThreadStart(ThreadProc));
            t.Start();
            //停止线程
            //t.Abort();

            for (var i = 0; i < 4; i++)
            {
                Console.WriteLine("主线程:做别的事{0}.", i);
                Thread.Sleep(0);
            }

            Console.WriteLine("主线程：要等ThreadProc执行完成");
            //阻塞调用线程，指导某个线程执行完成为止
            t.Join();

            for (var i = 5; i < 10; i++)
            {
                Console.WriteLine("主线程:做别的事{0}.", i);
                Thread.Sleep(0);
            }
        }

        private static void ThreadProc()
        {
            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine("ThreadProc：" + i);
                Thread.Sleep(0);
            }
        }
    }
}